/**
 * @description: 生产环境配置
 * @version: 0.0.1
 * @author: xiech
 * @Date: 2023-06-02 16:06:47
 */

import { MidwayConfig } from '@midwayjs/core';
import { configOptions } from '../interface';

export default (): MidwayConfig => {
  const config: configOptions = {};

  config.keywords = '生产';
  config.koa = {
    port: 8000,
  };

  config.midwayLogger = {
    default: {
      dir: '/acs/log',
    },
  };

  // 任务列表,如果使用任务列表请注意和其他项目和
  config.bull = {
    defaultQueueOptions: {
      redis: {
        port: 6379, // Redis port
        host: 'r-8vbcdq7j25ldrjgomt.redis.zhangbei.rds.aliyuncs.com', // Redis host
        password: 'MFredis1004',
        db: 39,
      },
    },
  };

  // 缓存 Redis
  config.redis = {
    client: {
      port: 6379, // Redis port
      host: 'r-8vbcdq7j25ldrjgomt.redis.zhangbei.rds.aliyuncs.com', // Redis host
      password: 'MFredis1004',
      db: 40,
    },
  };

  // 数据库
  config.sequelize = {
    dataSource: {
      default: {
        dialect: 'mysql',
        host: 'rm-8vbcjzts535i3hjn8.mysql.zhangbei.rds.aliyuncs.com', // 数据库IP
        port: 3306, // 数据库端口
        username: 'morefun_oa', // 数据库用户名（需要有创建表结构权限）
        password: 'Morefun1004', // 数据库密码
        database: 'morefun_oa', // 数据库IP
        encrypt: false,
        define: { charset: 'utf8' },
        timezone: '+08:00',
        // 或者扫描形式
        entities: ['**/entity/*.entity{.ts,.js}'],
        sync: false,
        repositoryMode: true,
      },
    },
  };

  //  钉钉登录回调地址
  config.dingtalkAuthConfig = {
    redirect_uri : 'https://morefun-oa.morefun.me/login',
    login_uri : 'https://login.dingtalk.com/oauth2/auth',
    oapi_uri: 'https://oapi.dingtalk.com',
    api_uri: 'https://api.dingtalk.com',
    mf_auth_base: 'https://morefun-oa.morefun.me/mf-auth/',
    oauth_path: 'https://morefun-oa.morefun.me/mf-oauth'
  }

  return config;
};
